<template>
  <div class="dog_wk">
    <Dog :imgs ="item.dogImgUrl" :names = "item.dogName" @buyDog = "dogMeat"   v-for="item in arr" :key="item.id"/>
    <span class="p_box">
      狗不狗:
      <dog-shopping :Name ="items" :dexs = "index" v-for="(items,index) in shopping" :key="index" @dels = "deLs" />
    </span>
  </div>
</template>

<script>
import Dog from './components/Dog.vue'
import dogShopping from './components/dogShopping.vue'
export default {
  data () {
    return {
      // 1. 准备数据
      arr: [
        {
          dogImgUrl:
        'http://nwzimg.wezhan.cn/contents/sitefiles2029/10146688/images/21129958.jpg',
          dogName: '博美'
        },
        {
          dogImgUrl:
        'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=1224576619,1307855467&fm=26&gp=0.jpg',
          dogName: '泰迪'
        },
        {
          dogImgUrl:
        'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2967740259,1518632757&fm=26&gp=0.jpg',
          dogName: '金毛'
        },
        {
          dogImgUrl:
        'https://pic1.zhimg.com/80/v2-7ba4342e6fedb9c5f3726eb0888867da_1440w.jpg?source=1940ef5c',
          dogName: '哈士奇'
        },
        {
          dogImgUrl:
        'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2967740259,1518632757&fm=26&gp=0.jpg',
          dogName: '阿拉斯加'
        },
        {
          dogImgUrl:
        'https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=1224576619,1307855467&fm=26&gp=0.jpg',
          dogName: '萨摩耶'
        }
      ],
      shopping: []
    }
  },
  components: {
    Dog,
    dogShopping
  },
  methods: {
    dogMeat (inda) {
      this.shopping.push(inda)
    },
    deLs (dogDel) {
      this.shopping.splice(dogDel, 1)
    }

  }
}
</script>
<style>
.dog_wk {
width: 800px;
height: 100%;
}
.p_box {
  width: 200px;
  margin-left: 40px;
}
</style>
